;(function ($, window, undefined){



	var pageObj = function (config){
		config = config || {};
		var defaults = pageObj.defaults,that=this;
		// 合并默认配置
		for (var i in defaults) {

			if (config[i] === undefined) config[i] = defaults[i];

		};
		return  pageObj.fn.init(config);
	};

	pageObj.fn = pageObj.prototype ={
		page : 0,
		init:function (config){
			var that = this;
			//分页按钮
			that.pageBtn = $(config.pageBtn);

			config.parm['pagesize']=config.parm['pagesize']||15;//翻页处理
			that.config = config;
			that._addEvent();

			return that;
		},
		_addEvent:function (){
			var that=this,
				config = that.config;
			that.pageBtn.bind('click',function (event){

				config.parm['page']=++that.page;//翻页处理

				that.send();

			});
		},
		//分页数据请求
		send:function (config){
			var that = this,
				config = that.config;

			$.ajax({
				type		: config.type,
				url			: config.url,
				data		: config.parm,
				dataType	: config.dataType,
				beforeSend	: config.beforeSend,
				success		: config.success
			});
			return that;
		},
		// 卸载事件代理
		_removeEvent: function () {
			var that = this,
				DOM = that.pageBtn;
			DOM.unbind().hide();
			page=0;
		},
		Time:function(nS){
			var d = new Date(parseInt(nS) * 1000);
			var year = d.getFullYear(),
				month = d.getMonth()+1,
				day = d.getDate();
			return year+"-"+month+"-"+day;
		}
	};
	pageObj.defaults = {
		type		:'post',
		url			:'/handle.php',
		parm		:{},
		dataType	:"json",
		success		:function (data){},
		beforeSend	:function (){},
		pageBtn		:"#page",
		dataBox		:".jf_main"
	};
	pageObj.money_html_tpl = ''//现金消费模版
		+'<div class="xf_info">'
		+'	<div class="xf_info_top">r_obj<span>r_time</span></div>'
		+'	<div class="xf_info_bottom">'
		+'		<ul>'
		+'			<li><p>消费金额</p><span>r_money</span></li>'
		+'			<li style=" background-image:none;"><p>获得积分</p><span>r_point</span></li>'
		+'		</ul>'
		+'		<div class="other">'
		+'			<p>消费店铺： r_s_name</p>'
		+'			<span>消费区域： r_city_name</span>'
		+'		</div>'
		+'	</div>'
		+'</div>';
	pageObj.jifen_html_tpl = ''//积分兑换模版
		+'<div class="jf_info">'
		+'	<div class="xf_info_top">r_obj<span>r_time</span></div>'
		+'	<div class="xf_info_bottom">'
		+'		<ul>'
		+'			<li style=" background-image:none;"><p>兑换积分</p><span>-r_point</span></li>'
		+'		</ul>'
		+'		<div class="other">'
		+'			<p>兑换店铺： r_s_name</p>'
		+'			<span>兑换区域： r_city_name</span>'
		+'		</div>'
		+'	</div>'
		+'</div>';

	window.pageObj = $.pageObj = pageObj;

})(this.$ || this.jQuery , this);